import { defineStore } from "pinia";
import { Names } from "./storeName";
const Login = (): Promise<{ result: number }> => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({ result: 123 });
    }, 3000);
  });
};
export const useTestStore = defineStore(Names.TEST, {
  state: () => {
    return {
      current: 1,
      name: "hello pinia",
    };
  },
  getters: {
    currentGetter():string{
        return `-${this.current}`
    }
  },
  actions: {
    setCurrent(num: number) {
      this.current = num;
    },
    async userLogin(){
       const res =  await Login()
       this.current = res.result
    }
  },
});
